import {Ref, ref} from 'vue'

export default function useBoolean(initValue: boolean = false) {
    const bool: Ref<boolean> = ref(initValue)

    function setBool(value: boolean) {
        bool.value = value
    }

    function setTrue() {
        setBool(true)
    }

    function setFalse() {
        setBool(false)
    }

    function toggle() {
        setBool(!bool.value)
    }

    return {
        bool,
        setBool,
        setTrue,
        setFalse,
        toggle
    }
}
